/*******************************************************************************
*   			Impacts of a Large-Scale Parenting Program: 				   *
*					Experimental Evidence from Chile						   *
********************************************************************************


	REQUIRES:	"${dt_final}panel_RR_indexes.dta"
	CREATES:	${out_tables}/T8A_ITT_parental_individual.xls
				
	WRITEN BY:  Italo Lopez  [italolop@usc.edu]

********************************************************************************
	Prepare data
*******************************************************************************/

	* Load data
	use "${dt_final}panel_RR_indexes.dta", clear


	* Establish macros for regressions

/*******************************************************************************
*   Set macros for regressions
*******************************************************************************/
	
	* Outcomes
	*-----------------------------------------------------------
	local childoutcomes  "zDCCSPunt zptevir_irtscore2 zt_score zcbcl_t_e zcbcl_t_i zibatt_sspi zibatt_ssai zibatt_sssr zas_raw_score" 
	local behaviors "home_score se_score disc_score" 
	local beliefs "zpstyle1 zpstyle2 zpstyle3 zPSCS zPSSS_family zPSSS_friends zPSSS_others zPSI_Distress zCESD zpacotis"	
	local child "zptevir_irtscore2 zcog_index zsoc_index" 

	* Controls
	*-----------------------------------------------------------

	macro  def Xvar1 "i.age_year i.gender"  	
	macro  def Xvar2 "i.age_year i.gender inc_qtaut_old i.pc_edu_mdsfin hh_mem hh_tipo"  	
	macro  def Xvar2old "i.gender inc_qtaut_old i.pc_edu_mdsfin_old hh_mem hh_tipo"  

	
	* Parental characteristics: WAIS and BFI and imputed wais 
	*-----------------------------------------------------------

	macro def parent_cha4 "BFI_ext BFI_ope BFI_con BFI_neu BFI_agr wais2 flag_wais"
	

/*******************************************************************************
	Table A8: ITT estimates of parental individual measures
*******************************************************************************/




	local parental "zhome_score_gsem znur_score_gsem zdisc_score_gsem1b zdisc_score_gsem2b zPSCS zpacotis zPSSS_family zPSSS_friends zPSSS_others zIAP_authoritarian zIAP_authoritative zIAP_permissive zPSI_Distress zCESD" 
	#delimit;
	foreach var of local parental {;
				
					
				* PANEL 3: ITT with Age and Gender and SES;
					xi: xtreg `var' i.TIPO $Xvar1 if x==1,  fe i(CENTRO_SALUD);
					estimates store `var'_itt1;
					
				* PANEL 4: ITT plus parental characteristics -; 	  
					xi: xtreg `var' i.TIPO $Xvar2 $parent_cha4 if x==1, fe i(CENTRO_SALUD);
					estimates store `var'_itt2;
					
	};


	#delimit cr
	***  Tables ITT Outcomes

		esttab zhome_score_gsem_itt1 znur_score_gsem_itt1 					  /*
		*/ zdisc_score_gsem1b_itt1 zdisc_score_gsem2b_itt1 zPSCS_itt1 		  /*
		*/ zpacotis_itt1 zPSSS_family_itt1 zPSSS_friends_itt1 				  /*
		*/ zPSSS_others_itt1 zIAP_authoritarian_itt1 zIAP_authoritative_itt1  /* 
		*/ zIAP_permissive_itt1 zPSI_Distress_itt1 zCESD_itt1  				  /*
		*/ using "${out_tables}/appendix/T8A_ITT_parental_individual.csv", replace f		  /* 
		*/ keep(_ITIPO_2 _ITIPO_3) 											 /*
		*/ cells("b(fmt(3)star)" "se(fmt(3)par)") 							 /*
		*/ star(* 0.10 ** 0.05 *** 0.01) 								     /*
		*/ stats(r2 N, fmt(2 0) labels("R-squared" "Observations")) legend	 /*
		*/ mtitles("Home Index" "PBC Nurturing Index"						 /* 
		*/ "PBC Negative Discipline Index" "PBC Positive Discipline Index" 	 /*
		*/ "Perceived Self-efficacy" "PACOTIS scale" 	 /*
		*/ "Perceived Family Support" "Perceived Friends Support" 			 /* 
		*/ "Perceived Support from Others" "Authoritative Style"			 /* 
		*/ "Authoritarian Style" "Permissive Style" "Parental Mental Health" /*
		*/ "Parental Stress""Depression" )  								 /*
		*/ title("Parental Practices (1): (age/gender)") 	varlabels(_ITIPO_2 "NEP-B" _ITIPO_3 "NEP-I")
		

		esttab zhome_score_gsem_itt2 znur_score_gsem_itt2 					 /*
		*/ zdisc_score_gsem1b_itt2 zdisc_score_gsem2b_itt2 zPSCS_itt2  		 /* 
		*/ zpacotis_itt2 zPSSS_family_itt2 zPSSS_friends_itt2 				 /* 
		*/ zPSSS_others_itt2 zIAP_authoritarian_itt2 zIAP_authoritative_itt2 /*
		*/ zIAP_permissive_itt2 zPSI_Distress_itt2 zCESD_itt2				  /*
		*/ using "${out_tables}/appendix/T8A_ITT_parental_individual.csv", append f		  /* 
		*/ keep(_ITIPO_2 _ITIPO_3) 											  /*
		*/ cells("b(fmt(3)star)" "se(fmt(3)par)") 							  /*
		*/ star(* 0.10 ** 0.05 *** 0.01) 									  /*
		*/ stats(r2 N, fmt(2 0) labels("R-squared" "Observations")) legend	  /*
		*/ mtitles("Home Index" "PBC Nurturing Index"						 /* 
		*/ "PBC Negative Discipline Index" "PBC Positive Discipline Index" 	 /*
		*/ "Perceived Self-efficacy" "PACOTIS scale" 	 /*
		*/ "Perceived Family Support" "Perceived Friends Support" 			 /* 
		*/ "Perceived Support from Others" "Authoritative Style"			 /* 
		*/ "Authoritarian Style" "Permissive Style" "Parental Mental Health" /*
		*/ "Parental Stress""Depression" )  								 /*
		*/ title("Parental Practices (2): + caregiver's education, IQ and personality traits; hh'ld income, hh'ld size") 	/*
		*/ varlabels(_ITIPO_2 "NEP-B" _ITIPO_3 "NEP-I")

	
